package com.biaobiaoqi.scoreanalysis.administrator.action;

import java.util.Map;

import javax.annotation.Resource;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.struts2.interceptor.SessionAware;

import com.biaobiaoqi.scoreanalysis.service.IAdministratorService;
import com.opensymphony.xwork2.ActionSupport;

public class SaveAdminInfo extends ActionSupport implements SessionAware{
	Log log = LogFactory.getLog(SaveAdminInfo.class);
 	/**
	 * 
	 */
	private static final long serialVersionUID = -4182484130965768377L;
  	private String userName;
 	private Map<String, Object> session;


	@Resource
 	private IAdministratorService administratorService;

	public String execute() {
		log.debug("userName:"+userName);
		try {
			Integer userId = (Integer) session.get("userId");
			administratorService.modifyAdministratorName(userId, userName);
			return SUCCESS;
		} catch (Exception e) {
			log.error("save admin info failed.", e);
			return ERROR;
		}
	}

	public IAdministratorService getAdministratorService() {
		return administratorService;
	}

	public void setAdministratorService(
			IAdministratorService administratorService) {
		this.administratorService = administratorService;
	}

 
 
	public String getUserName() {
		return userName;
	}

	public void setUserName(String userName) {
		this.userName = userName;
	}

	@Override
	public void setSession(Map<String, Object> session) {
		// TODO Auto-generated method stub
		this.session = session;
	}
}
